package com.designpattern.template.java8;

import java.math.BigDecimal;
import java.util.function.Consumer;

/**
 * 项目名称: java_algorithm
 * @ClassName BankBusinessHandler
 * @Description
 * @Author huipanxing huipanxing@chinasofti.com   @Date 2021/9/1 18:09
 */
public class BankBusinessHandler {

    private void execute(Consumer<BigDecimal> consumer){
        getNumber();
        consumer.accept(null);
        judge();
    }

    /**
     * 功能描述: 取号成功
     * @param
     * @return void
     */
    private void getNumber(){
        System.out.println("取号成功");
    }

    /**
     * 功能描述: 评价
     * @param
     * @return void
     */
    private void judge(){
        System.out.println("给个好评");
    }

    /**
     * 功能描述: 业务处理
     * @param amount
     * @return void
     */
    public void save(BigDecimal amount) {
        execute(a -> System.out.println("取" + amount+"块钱"));
    }

    public void draw(BigDecimal amount){
        execute(a-> System.out.println("draw"+amount));
    }

    public void moneyManage(BigDecimal amount){
        execute(a-> System.out.println("manage"+amount));
    }

    public static void main(String[] args) {
        BankBusinessHandler bankBusinessHandler=new BankBusinessHandler();
        bankBusinessHandler.save(new BigDecimal("100"));
        bankBusinessHandler.draw(new BigDecimal("100"));
        bankBusinessHandler.moneyManage(new BigDecimal("100"));
    }
}
